/**
 * 
 */
package counter;

import barrier.BarrierType;

/**
 * 
 * 
 *                      DONT USE!!!
 *                      
 *                      
 *                      probably should be deleted.
 * 
 *              
 *              
 *              
 *              
 * @author Yoni Seroussi
 * @author Roei Raviv
 *
 * to be run on the capricorn machine, expecting 64 threads to run on
 * one "side" and the other on second "side" - to minimize the expensive memory
 * updates between 2 sides.
 * 
 * using one globalSense boolean to communicate between both sizes.
 * only last thread should update this flag. 
 */
public class SplittedCounter extends Counter implements ICounter {

    private volatile boolean _globalSense;
    
    // counters on both sides.
    private CounterWithBarrier _counter1;
    
    @SuppressWarnings("unused")
    private byte[] pad = new byte[128*1024*1024];
    
    private CounterWithBarrier _counter2; 
    
    /**
     * C'tor
     * @param numOfThreads
     */
    public SplittedCounter(BarrierType barrierType, int numOfThreads) {
        super();
        _globalSense = false;
        _counter1 = new CounterWithBarrier(barrierType, numOfThreads);
        _counter2 = new CounterWithBarrier(barrierType, numOfThreads);
    }

    /**
     * @param isFirst
     * @return
     */
    public CounterWithBarrier getInnerCounter(boolean isFirst) {
        return (isFirst ? _counter1 : _counter2);
    }
    
    /* (non-Javadoc)
     * @see counter.ICounter#getValue()
     */
    public int getValue() {
        
        return super.getValue();
    }

    /* (non-Javadoc)
     * @see counter.ICounter#setValue(int)
     */
    public void setValue(int value) {
        super.setValue(value);
    }    
}
